import 'package:flutter/material.dart';

import '../customizable.dart';
import '../extentions/build_context_extentions.dart';

class NoDataWidget extends StatelessWidget {
  final String? description;
  final String imageName;
  final bool showImage;
  final TextStyle descriptionStyle;

  const NoDataWidget({
    Key? key,
    this.description,
    this.imageName = "ico_no_data",
    this.showImage = true,
    this.descriptionStyle = const TextStyle(
      fontSize: 14,
      color: Color(0xFFBFBFBF),
    ),
  }) : super(key: key);

  const NoDataWidget.noSearchResult() : this(description: "没有匹配的结果, 请修改关键重新搜索");

  @override
  Widget build(BuildContext context) {
    return buildNoDataSection(context);
  }

  Widget buildNoDataSection(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          if (showImage == true)
            Image.asset(
              context.imageAsset(imageName),
              color: Theme.of(context).primaryColor,
            ),
          Padding(
            padding: const EdgeInsets.only(top: 10),
            child: Align(
              alignment: Alignment(0, 0),
              child: Text(
                description ?? CustomizableFeatures.strings.no_data,
                style: descriptionStyle,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
